package cn.stevenyang.signals;

public class CounterSignal extends Signal {
    public int getTicket() {
        return ticket;
    }

    public void setTicket(int ticket) {
        this.ticket = ticket;
    }

    private int ticket;
    public CounterSignal(int initialValue) {
        this.ticket = initialValue;
    }

    public int increment() {
        this.ticket++;
        return this.ticket;
    }

    public int decrement() {
        if (!isCountOver()) {
            this.ticket--;
        }
        return this.ticket;
    }

    public Boolean isCountOver() {
        return this.ticket == 0;
    }
}
